Dynomotion

Group: DynoMotion Message: 12464 From: embraced338 Date: 10/31/2015
Subject: Routine for a linear tool changer

Hi All, 


I'm setting up a router that has a row of tools at the back of the machine.


They would all be at a fixed and known position once the machine has been homed.


The sequence of events would be something like:

- Go to the position of the last tool that was retrieved (so it selects an empty slot)

- turn on eject tool solenoid to remove tool, turn on solenoid to force air out of the taper for cleaning

- go to new tool position

- turn on eject tool solenoid to retrieve tool

- leave tool holder in a way that would not destroy the holder (only move in one axis i suppose?)


How would one write a program to execute a tool change with that sort of sequence? 

Are there any examples that are similar to this?



Thanks,



Lindsay

Group: DynoMotion Message: 12466 From: TK Date: 10/31/2015
Subject: Re: Routine for a linear tool changer
Hi Lindsay,

The examples we have in \C Programs\ToolChanger are state driven which is probably an unnecessary  complication for you.  The State Driven approach avoids using and loading an extra Thread in KFLOP.  But if KMotionCNC will be always invoking Tool Changes then a simpler sequential program in another Thread should work fine.

We can help walk you through this.  But you will need a much more detailed specification for what needs to take place.  You describe turning on solenoids but never turn them off.  What are the positions to move to?  What directions to approach from?

You might read this:
http://www.cnczone.com/forums/dynomotion-kflop-kanalog/284094-tool-change-code-ss2v05pmf4.html

I'd suggest doing the whole process manually step-by-step to see if you can do a successful tool change.  Write down every single step.  Which I/O bit, which polarity, how to calculate the positions, etc...

After that we can help you code this up.  I'd like to put this example on our new wiki if you don't mind.

HTH
Regards
TK




On 10/31/2015 6:13 AM, embraced338@... [DynoMotion] wrote:
 

Hi All, 


I'm setting up a router that has a row of tools at the back of the machine.


They would all be at a fixed and known position once the machine has been homed.


The sequence of events would be something like:

- Go to the position of the last tool that was retrieved (so it selects an empty slot)

- turn on eject tool solenoid to remove tool, turn on solenoid to force air out of the taper for cleaning

- go to new tool position

- turn on eject tool solenoid to retrieve tool

- leave tool holder in a way that would not destroy the holder (only move in one axis i suppose?)


How would one write a program to execute a tool change with that sort of sequence? 

Are there any examples that are similar to this?



Thanks,



Lindsay


Group: DynoMotion Message: 12467 From: embraced338 Date: 10/31/2015
Subject: Re: Routine for a linear tool changer
Hi Tom,

I would love to have it featured on the Wiki, I'm certain that a lot of other users would like to see an example like this - it's a pretty common method to hold tools.


I have attached a snippet that only has definitions, and a sequence of events that I would like to execute (suggestions are very welcome). I haven't attempted to write any code yet as I'm likely to go down a path that doesn't make much sense (I have limited aptitude for programming!).

Also attached is a photo of the tool changing apparatus (the holder) to give some context to my sequence of events described in the code snippet.

Also, as the machine currently only has 4 tool holders, some code to check for a tool holder that is invalid or not specified would be good. Ideas for this are welcomed.

CODE:


#include "KMotionDef.h"

//-----------------------------------------
// LINEAR TOOL CHANGING
//-----------------------------------------

//---------Absolute position of tool holders
#define HOLDER_1 (X100Y1300Z-200)
#define HOLDER_2 (X200Y1300Z-200)
#define HOLDER_3 (X300Y1300Z-200)
#define HOLDER_4 (X400Y1300Z-200)
#define TOOL_HEIGHT_PLATE (X50Y50) //absolute position of the tool height setting plate
#define TOOL_CHANGE_SAFE_POS (X250Y1200) // absolute position to move to that 
// is permanently unobstructed, and safe to move down in Z
#define Y_AXIS_SAFE_DISTANCE 100  // distance in mm to approach tool holder
//---------

//--------- Spindle IO bits
#define CLAW_EJECT 58 // IO bit to eject tool from spindle (KONNECT OUTPUT 10)
#define SPINDLE_CLEAN 59 // IO bit to blow air out of spindle taper (KONNECT OUTPUT 11)
#define CLAW_LOOSE 1048 // IO bit to sense whether the claw has ejected (KONNECT INPUT 24)
#define TOOL_SENSE 1049 // IO bit to sense whether the a tool is in the spindle (KONNECT INPUT 24)
//---------

#define TOOL_VAR 9         // Tool changer desired new tool Var
#define LAST_TOOL_VAR 7   // Tool changer Last tool position is saved globally in this Var
#define CLAMP_TIME 1.0     // seconds to wait for the clamp/unclamp
#define TOOL_HEIGHT_BIT 1055 //bit to read tool height plate (KONNECT INPUT 31)

#define Z_SAFE_HEIGHT 100   // relative distance in mm to move to clear the top of the tool taper
#define Z_TOOL_RETRACT_SPEED 5000 //speed in counts/second to move spindle up after tool has been ejected


//SEQUENCE OF EVENTS:

// - Remove tool in spindle by going to holder of current tool
// - Rapid to Z Home to clear any work that may be on the table
// - Rapid to TOOL_CHANGE_SAFE_POS to execute a safe negative Z move
// - Approach tool holder by matching Z height of tool flange currently in spindle with tool holder                            claw
// - After matching height above, approach tool holder by moving to holder X position
// - After matching X position, match tool Y position
// - Move only in Y position until current position matches tool holder position (maybe disable X                            axis?)

// - Eject tool 
// - Turn on CLAW_EJECT bit to remove tool from spindle
// - Turn on SPINDLE_CLEAN bit to remove any debris from taper and tools
// - Wait for time in seconds defined by CLAMP_TIME
// - Read CLAW_LOOSE bit to see whether the tool is loose, to make a safe Z move without                               destroying tool holder
// - If CLAW_LOOSE bit is high, something has gone wrong;
// halt everything and display message indicating failure
// - Move Z axis up at speed defined by 'Z_TOOL_RETRACT_SPEED', to Z_SAFE_HEIGHT
// - Read TOOL_SENSE bit to see whether the tool has been successfully ejected from the spindle
// - If TOOL_SENSE bit is high, something has gone wrong; 
// halt everything and display message indicating failure

// - Move to position of requested tool
// - Rapid move to absolute position of new tool only in X and Y
// - Move to tool Z position at Z_TOOL_RETRACT_SPEED

// - Engage new tool
// - CLAW_EJECT and SPINDLE_CLEAN bits are currently high from tool removal operation
// - Turn off CLAW_EJECT and SPINDLE_CLEAN bits to engage tool
// - Wait for time in seconds defined by CLAMP_TIME
// - Check to see if CLAW_LOOSE and TOOL_SENSE are high; if either are not, 
// something has gone wrong; halt everything and display message indicating failure
// - Tool has been engaged
// - Tell KmotionCNC that the current tool is the requested tool

// - Leave tool holder by moving Y axis by the negative value of Y_AXIS_SAFE_DISTANCE
// - Rapid to Z home

// - Tool change has been successful, continue executing G-Code program
// - Optionally, go to position of TOOL_HEIGHT_PLATE to execute a tool offset measuring operation


---------CODE GOES HERE------------


  @@attachment@@
Group: DynoMotion Message: 12468 From: Hardy Family Date: 11/1/2015
Subject: Re: Routine for a linear tool changer [2 Attachments]

Having recently coded a similar sort of tool changer, I would recommend a few debugging tips as follows:

Between every elementary step in the process, insert a function call which allows an extra input to be used as a "single step" control.  The function should take a string parameter which is then displayed on the console so that you know what the program is about to do.  It then waits for the input to toggle on then off before returning.

When your code is working, leave the function calls in place, but comment out the body of the function.  We actually use that little function to perform sanity checks (such as checking that all axes are enabled) so that there is consistent handling of estop and so on.

We also found it a good idea to tune the axis parameters so that they were sensitive to unexpectedly high forces.  For example, assuming you have linear encoders, you can set the allowable following error to to a small value, then test by exerting hand force to make sure it errors out and stops motion.  If you don't have encoders, then at least slow down the max velocity so you have more time to react if something doesn't look right.

Regards,
Sjh

On Oct 31, 2015 10:56 PM, "embraced338@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:
 
[Attachment(s) from embraced338@... [DynoMotion] included below]

Hi Tom,


I would love to have it featured on the Wiki, I'm certain that a lot of other users would like to see an example like this - it's a pretty common method to hold tools.


I have attached a snippet that only has definitions, and a sequence of events that I would like to execute (suggestions are very welcome). I haven't attempted to write any code yet as I'm likely to go down a path that doesn't make much sense (I have limited aptitude for programming!).

Also attached is a photo of the tool changing apparatus (the holder) to give some context to my sequence of events described in the code snippet.

Also, as the machine currently only has 4 tool holders, some code to check for a tool holder that is invalid or not specified would be good. Ideas for this are welcomed.

CODE:


#include "KMotionDef.h"

//-----------------------------------------
// LINEAR TOOL CHANGING
//-----------------------------------------

//---------Absolute position of tool holders
#define HOLDER_1 (X100Y1300Z-200)
#define HOLDER_2 (X200Y1300Z-200)
#define HOLDER_3 (X300Y1300Z-200)
#define HOLDER_4 (X400Y1300Z-200)
#define TOOL_HEIGHT_PLATE (X50Y50) //absolute position of the tool height setting plate
#define TOOL_CHANGE_SAFE_POS (X250Y1200) // absolute position to move to that 
// is permanently unobstructed, and safe to move down in Z
#define Y_AXIS_SAFE_DISTANCE 100  // distance in mm to approach tool holder
//---------

//--------- Spindle IO bits
#define CLAW_EJECT 58 // IO bit to eject tool from spindle (KONNECT OUTPUT 10)
#define SPINDLE_CLEAN 59 // IO bit to blow air out of spindle taper (KONNECT OUTPUT 11)
#define CLAW_LOOSE 1048 // IO bit to sense whether the claw has ejected (KONNECT INPUT 24)
#define TOOL_SENSE 1049 // IO bit to sense whether the a tool is in the spindle (KONNECT INPUT 24)
//---------

#define TOOL_VAR 9         // Tool changer desired new tool Var
#define LAST_TOOL_VAR 7   // Tool changer Last tool position is saved globally in this Var
#define CLAMP_TIME 1.0     // seconds to wait for the clamp/unclamp
#define TOOL_HEIGHT_BIT 1055 //bit to read tool height plate (KONNECT INPUT 31)

#define Z_SAFE_HEIGHT 100   // relative distance in mm to move to clear the top of the tool taper
#define Z_TOOL_RETRACT_SPEED 5000 //speed in counts/second to move spindle up after tool has been ejected


//SEQUENCE OF EVENTS:

// - Remove tool in spindle by going to holder of current tool
// - Rapid to Z Home to clear any work that may be on the table
// - Rapid to TOOL_CHANGE_SAFE_POS to execute a safe negative Z move
// - Approach tool holder by matching Z height of tool flange currently in spindle with tool holder                            claw
// - After matching height above, approach tool holder by moving to holder X position
// - After matching X position, match tool Y position
// - Move only in Y position until current position matches tool holder position (maybe disable X                            axis?)

// - Eject tool 
// - Turn on CLAW_EJECT bit to remove tool from spindle
// - Turn on SPINDLE_CLEAN bit to remove any debris from taper and tools
// - Wait for time in seconds defined by CLAMP_TIME
// - Read CLAW_LOOSE bit to see whether the tool is loose, to make a safe Z move without                               destroying tool holder
// - If CLAW_LOOSE bit is high, something has gone wrong;
// halt everything and display message indicating failure
// - Move Z axis up at speed defined by 'Z_TOOL_RETRACT_SPEED', to Z_SAFE_HEIGHT
// - Read TOOL_SENSE bit to see whether the tool has been successfully ejected from the spindle
// - If TOOL_SENSE bit is high, something has gone wrong; 
// halt everything and display message indicating failure

// - Move to position of requested tool
// - Rapid move to absolute position of new tool only in X and Y
// - Move to tool Z position at Z_TOOL_RETRACT_SPEED

// - Engage new tool
// - CLAW_EJECT and SPINDLE_CLEAN bits are currently high from tool removal operation
// - Turn off CLAW_EJECT and SPINDLE_CLEAN bits to engage tool
// - Wait for time in seconds defined by CLAMP_TIME
// - Check to see if CLAW_LOOSE and TOOL_SENSE are high; if either are not, 
// something has gone wrong; halt everything and display message indicating failure
// - Tool has been engaged
// - Tell KmotionCNC that the current tool is the requested tool

// - Leave tool holder by moving Y axis by the negative value of Y_AXIS_SAFE_DISTANCE
// - Rapid to Z home

// - Tool change has been successful, continue executing G-Code program
// - Optionally, go to position of TOOL_HEIGHT_PLATE to execute a tool offset measuring operation


---------CODE GOES HERE------------


Group: DynoMotion Message: 12473 From: TK Date: 11/2/2015
Subject: Re: Routine for a linear tool changer [2 Attachments]
Attachments :
    Hi Lindsay,

    See attached C Program.  Please check it over.  There were a few things unclear.

    #1 It isn't clear if the tool holder are "in the back" in Y or X ??

    #2 there seems to be an extra move when unloading that i don't understand.

    #3 what is your resolution in counts/mm ??

    #4 you didn't clearly specify the polarities of the outputs or inputs.

    #5 Check the Axis Definitions

    Let us know how much makes sense

    Regards
    TK


    On 10/31/2015 10:56 PM, embraced338@... [DynoMotion] wrote:
     

    Hi Tom,


    I would love to have it featured on the Wiki, I'm certain that a lot of other users would like to see an example like this - it's a pretty common method to hold tools.


    I have attached a snippet that only has definitions, and a sequence of events that I would like to execute (suggestions are very welcome). I haven't attempted to write any code yet as I'm likely to go down a path that doesn't make much sense (I have limited aptitude for programming!).

    Also attached is a photo of the tool changing apparatus (the holder) to give some context to my sequence of events described in the code snippet.

    Also, as the machine currently only has 4 tool holders, some code to check for a tool holder that is invalid or not specified would be good. Ideas for this are welcomed.

    CODE:


    #include "KMotionDef.h"

    //-----------------------------------------
    // LINEAR TOOL CHANGING
    //-----------------------------------------

    //---------Absolute position of tool holders
    #define HOLDER_1 (X100Y1300Z-200)
    #define HOLDER_2 (X200Y1300Z-200)
    #define HOLDER_3 (X300Y1300Z-200)
    #define HOLDER_4 (X400Y1300Z-200)
    #define TOOL_HEIGHT_PLATE (X50Y50) //absolute position of the tool height setting plate
    #define TOOL_CHANGE_SAFE_POS (X250Y1200) // absolute position to move to that 
    // is permanently unobstructed, and safe to move down in Z
    #define Y_AXIS_SAFE_DISTANCE 100  // distance in mm to approach tool holder
    //---------

    //--------- Spindle IO bits
    #define CLAW_EJECT 58 // IO bit to eject tool from spindle (KONNECT OUTPUT 10)
    #define SPINDLE_CLEAN 59 // IO bit to blow air out of spindle taper (KONNECT OUTPUT 11)
    #define CLAW_LOOSE 1048 // IO bit to sense whether the claw has ejected (KONNECT INPUT 24)
    #define TOOL_SENSE 1049 // IO bit to sense whether the a tool is in the spindle (KONNECT INPUT 24)
    //---------

    #define TOOL_VAR 9         // Tool changer desired new tool Var
    #define LAST_TOOL_VAR 7   // Tool changer Last tool position is saved globally in this Var
    #define CLAMP_TIME 1.0     // seconds to wait for the clamp/unclamp
    #define TOOL_HEIGHT_BIT 1055 //bit to read tool height plate (KONNECT INPUT 31)

    #define Z_SAFE_HEIGHT 100   // relative distance in mm to move to clear the top of the tool taper
    #define Z_TOOL_RETRACT_SPEED 5000 //speed in counts/second to move spindle up after tool has been ejected


    //SEQUENCE OF EVENTS:

    // - Remove tool in spindle by going to holder of current tool
    // - Rapid to Z Home to clear any work that may be on the table
    // - Rapid to TOOL_CHANGE_SAFE_POS to execute a safe negative Z move
    // - Approach tool holder by matching Z height of tool flange currently in spindle with tool holder                            claw
    // - After matching height above, approach tool holder by moving to holder X position
    // - After matching X position, match tool Y position
    // - Move only in Y position until current position matches tool holder position (maybe disable X                            axis?)

    // - Eject tool 
    // - Turn on CLAW_EJECT bit to remove tool from spindle
    // - Turn on SPINDLE_CLEAN bit to remove any debris from taper and tools
    // - Wait for time in seconds defined by CLAMP_TIME
    // - Read CLAW_LOOSE bit to see whether the tool is loose, to make a safe Z move without                               destroying tool holder
    // - If CLAW_LOOSE bit is high, something has gone wrong;
    // halt everything and display message indicating failure
    // - Move Z axis up at speed defined by 'Z_TOOL_RETRACT_SPEED', to Z_SAFE_HEIGHT
    // - Read TOOL_SENSE bit to see whether the tool has been successfully ejected from the spindle
    // - If TOOL_SENSE bit is high, something has gone wrong; 
    // halt everything and display message indicating failure

    // - Move to position of requested tool
    // - Rapid move to absolute position of new tool only in X and Y
    // - Move to tool Z position at Z_TOOL_RETRACT_SPEED

    // - Engage new tool
    // - CLAW_EJECT and SPINDLE_CLEAN bits are currently high from tool removal operation
    // - Turn off CLAW_EJECT and SPINDLE_CLEAN bits to engage tool
    // - Wait for time in seconds defined by CLAMP_TIME
    // - Check to see if CLAW_LOOSE and TOOL_SENSE are high; if either are not, 
    // something has gone wrong; halt everything and display message indicating failure
    // - Tool has been engaged
    // - Tell KmotionCNC that the current tool is the requested tool

    // - Leave tool holder by moving Y axis by the negative value of Y_AXIS_SAFE_DISTANCE
    // - Rapid to Z home

    // - Tool change has been successful, continue executing G-Code program
    // - Optionally, go to position of TOOL_HEIGHT_PLATE to execute a tool offset measuring operation


    ---------CODE GOES HERE------------



    Group: DynoMotion Message: 12474 From: embraced338 Date: 11/3/2015
    Subject: Re: Routine for a linear tool changer
    Hi Tom,

    I don't see any attachment. Maybe I'm not looking in the right place..

    #1: Tools are in the back of the Y axis. Attached is a render of the machine - X going from left to right, Y going towards and away from the viewer.

    #2: What move are you referring to? I don't see anything that is ambiguous (perhaps I'm blind)

    #3: Resolution is 800 counts/mm (20320/inch)

    #4: For polarities, I typically have the Konnect input banks using a 0v common, driven with a 24v supply. This much I can manage.

    #5: Not sure whether you're referring to my current initialisation file or yours.
    Group: DynoMotion Message: 12475 From: TK Date: 11/3/2015
    Subject: Re: Routine for a linear tool changer
    Hi Lindsay,

    Strange my attached file didn't seem to show up.

    Anyways I placed it on the wiki here:
    http://www.dynomotion.com/wiki/index.php?title=Tool_Changer_-_router_linear_4_Tools_-_C_Program

    Regarding:

    #1 - thanks.  Verify the motions are all correct

    #2 - see the (seems like you already moved in Y):

        // - Move only in Y position until current position matches tool holder position (maybe disable Xaxis?)
        // ???

    #3 - ok I coded that in

    #4 - I'm more interested in the logical polarities.   ie does TOOL_SENSE checked mean the tool is sensed or not sensed?

    #5 - Make sure the AXISX, AXISY, AXISZ definitions I coded in the program match your system

    Regards
    TK

    On 11/3/2015 1:22 AM, embraced338@... [DynoMotion] wrote:
     

    Hi Tom,


    I don't see any attachment. Maybe I'm not looking in the right place..

    #1: Tools are in the back of the Y axis. Attached is a render of the machine - X going from left to right, Y going towards and away from the viewer.

    #2: What move are you referring to? I don't see anything that is ambiguous (perhaps I'm blind)

    #3: Resolution is 800 counts/mm (20320/inch)

    #4: For polarities, I typically have the Konnect input banks using a 0v common, driven with a 24v supply. This much I can manage.

    #5: Not sure whether you're referring to my current initialisation file or yours.

    Group: DynoMotion Message: 12489 From: embraced338 Date: 11/5/2015
    Subject: Re: Routine for a linear tool changer
    Thanks so much Tom.

    I'll give it a go and report back - perhaps with a video too.